<template>
  <div style="text-align: left;margin-left: 30px">
    <div style="margin: 20px 20px">
      <el-page-header @back="goBack" content="新增项目"></el-page-header>
    </div>
    <div>
      <el-form :model="projectInfo" inline label-width="80px" style="width: 600px" label-position="right">
        <el-form-item label="项目名称:">
          <el-input style="width: 400px" v-model="projectInfo.project_name"></el-input>
        </el-form-item>
        <el-form-item label="负责人:">
          <el-input style="width: 400px" v-model="projectInfo.responsible_name"></el-input>
        </el-form-item>
        <el-form-item label="测试人员:">
          <el-input style="width: 400px" v-model="projectInfo.test_user"></el-input>
        </el-form-item>
        <el-form-item label="开发人员:">
          <el-input style="width: 400px" v-model="projectInfo.dev_user"></el-input>
        </el-form-item>
        <el-form-item label="发布应用:">
          <el-input style="width: 400px" v-model="projectInfo.publish_app"></el-input>
        </el-form-item>
        <el-form-item label="简要描述:">
          <el-input type="textarea" :rows="2" style="width: 400px" v-model="projectInfo.simple_desc"></el-input>
        </el-form-item>
        <el-form-item label="其他信息:">
          <el-input type="textarea" :rows="2" style="width: 400px" v-model="projectInfo.other_desc"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="projectAdd()">提 交</el-button>
      </div>
    </div>
  </div>
</template>

<script>

export default {
    name: "projectAdd",
    data() {
        return {
            projectInfo: {
                project_name: "",
                responsible_name: "",
                test_user: "",
                dev_user: "",
                publish_app: "",
                simple_desc: "",
                other_desc: "",
            },
            msg: '',

        }
    },
    methods: {
        projectAdd() {
            this.$axios.post("/api/projectAdd/", {"projectInfo": this.projectInfo})
                .then(res => {
                        if (res.data.msgCode === "1") {
                            console.log("新增项目成功");
                            this.$router.push("/base/projectList")
                        } else if (res.data.msgCode === '0') {
                            this.$message('项目名称重复');
                        } else {
                            console.log("新增项目失败");
                        }
                    }
                ).catch(error => {
                console.log(error);
            })
        },
        // 页面返回
        goBack() {
            console.log('go back');
            this.$router.back();
        },
    }
}
</script>

<style scoped>

</style>
